<template>
    <div ref="trafficCharts" class="trafficCharts">

    </div>
</template>

<script>
import echarts from 'echarts'
export default {
    name: 'KeyboardChart',
    props: {
        xData: {
            type: Object,
            default: () => []
        },
        seriesData: {
            type: Object,
            default: () => {}
        },

    },
    mounted() {
        this.onInit()
    },
    methods: {
        onInit() {
            let chartDom = this.$refs['trafficCharts'];
            let myChart = echarts.init(chartDom);
            let option = {
                tooltip: {
                    trigger: 'axis'
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: this.xData
                },
                yAxis: {
                    type: 'value'
                },
                legend: {
                    data: ['流量监控']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    top: '15%',
                    bottom: '4%',
                    containLabel: true
                },
                series: [
                    {
                        name: '流量监控',
                        data: this.seriesData,
                        type: 'line',
                        smooth: true,
                        lineStyle: {
                            color: '#5087ec'
                        },
                        areaStyle: {
                            color: '#dce7fb'
                        },
                        itemStyle: {
                            normal: {
                                color: '#5087ec', //折线点的颜色
                                borderColor: '#5087ec', //拐点边框颜色
                                borderWidth: 2, //拐点边框大小
                            },
                        }
                    }
                ]
            };
            option && myChart.setOption(option);
            myChart.resize({

            });
        }
    }

}
</script>

<style scoped>
.trafficCharts {
    width: 100%;
    height: 100%;
}
</style>